﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DownLoad.UserControls
{
    /// <summary>
    /// OperationPDF.xaml 的交互逻辑
    /// </summary>
    public partial class OperationPDF : UserControl
    {
        private bool IsLoadedFile = false;//记录文件是否显示
        public OperationPDF()
        {
            InitializeComponent();
        }
        private void buttonZoomIn_Click(object sender, RoutedEventArgs e)
        {
            if (IsLoadedFile)
            {
                moonPdfPanel.ZoomIn();
            }
        }

        private void buttonZoomOut_Click(object sender, RoutedEventArgs e)
        {
            if (IsLoadedFile)
            {
                moonPdfPanel.ZoomOut();
            }
        }

        private void buttonNormal_Click(object sender, RoutedEventArgs e)
        {
            if (IsLoadedFile)
            {
                moonPdfPanel.Zoom(1.0);
            }
        }
        private void buttonFitToHeight_Click(object sender, RoutedEventArgs e)
        {
            if (IsLoadedFile)
            {
                moonPdfPanel.ZoomToHeight();
            }
        }

        private void buttonSinglePage_Click(object sender, RoutedEventArgs e)
        {
            if (IsLoadedFile)
            {
                moonPdfPanel.ViewType = MoonPdfLib.ViewType.Facing;
            }
        }

        private void buttonFacing_Click(object sender, RoutedEventArgs e)
        {

            if (IsLoadedFile)
            {
                moonPdfPanel.ViewType = MoonPdfLib.ViewType.SinglePage;
            }
        }
        private void buttonOpen_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string SOPPath = AppDomain.CurrentDomain.BaseDirectory+"SOP.pdf";
                moonPdfPanel.OpenFile(SOPPath);
                IsLoadedFile = true;
            }
            catch 
            {
                IsLoadedFile = false;
            }
           
        }
    }
}
